package com.liu.BITOperation;

import java.util.Scanner;

public class SwapOddAndEven {
    // 将整数的奇偶位互换
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int Number = sc.nextInt();
        int odd = Number & 0xaaaaaaaa; // 和1010 1010 1010 1010 . . . .;
        int even = Number & 0x55555555; // 和 0101 0101 0101 0101 . . . .;
        int result =  (odd >> 1) ^ (even << 1);
        System.out.println("交换前："+Integer.toString(Number,2));
        System.out.println("交换后："+Integer.toString(result,2));
    }
}
